package com.zhz.smbmsjpa.repository;

import com.zhz.smbmsjpa.pojo.Provider;
import com.zhz.smbmsjpa.vo.ProviderInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface ProviderRepository extends JpaRepository<Provider,Long> {

    public List<Provider> findByProNameLike(String proName);

    @Query("select p from Provider p where p.id=?1")
    public List<Provider> findByProId(Long proId);

    @Query("select p from Provider p where p.createdBy=?1")
    public Page<Provider> findPageByProId(Long createdBy, Pageable pageable);

    @Query("select p.id,p.proCode,p.proName,p.proDesc,p.createdBy" +
            ",u.id,u.userName,u.userCode from User u,Provider p " +
            " where u.id=p.createdBy and p.id=?1")
    public ProviderInfo getProviderInfo(Long proId);
}
